/*
 * \brief  Client-side PCI-session interface
 * \author Norman Feske
 * \date   2008-01-28
 */

/*
 * Copyright (C) 2008-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__PCI_SESSION__CLIENT_H_
#define _INCLUDE__PCI_SESSION__CLIENT_H_

#include <pci_session/capability.h>
#include <base/ipc.h>

namespace Pci {

	class Session_client : public Session
	{
		private:

			Genode::Msgbuf<64> _snd_msg, _rcv_msg;
			Genode::Ipc_client _ipc_client;

		public:

			/**
			 * Constructor
			 */
			Session_client(Session_capability session)
			: _ipc_client(session, &_snd_msg, &_rcv_msg) { }


			/***************************
			 ** PCI session interface **
			 ***************************/

			Device_capability first_device()
			{
				Device_capability device;
				_ipc_client << FIRST_DEVICE
				            << Genode::IPC_CALL >> device;
				return device;
			}

			Device_capability next_device(Device_capability prev_device)
			{
				Device_capability device;
				_ipc_client << NEXT_DEVICE << prev_device
				            << Genode::IPC_CALL >> device;
				return device;
			}

			void release_device(Device_capability device)
			{
				_ipc_client << RELEASE_DEVICE << device << Genode::IPC_CALL;
			}
	};
}

#endif /* _INCLUDE__PCI_SESSION__CLIENT_H_ */
